package com.hqbzl.c1.sources;

import com.hqbzl.c1.pc.Test;
import sun.misc.Unsafe;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

public class TestMap {
    private int a;

    public static void main(String[] args) throws Exception {
        final HashMap<Integer, String> map = new HashMap<>();
        final String lisi = map.put(1, "lisi");
        final ConcurrentHashMap<Integer, String> map1 = new ConcurrentHashMap<>();
        map1.put(1, "abc");
        final Unsafe unsafe = Unsafe.getUnsafe();

        final Field a = TestMap.class.getDeclaredField("a");
        final long offset = unsafe.objectFieldOffset(a);
        System.out.println("offset = " + offset);
        //final long offset1 = unsafe.objectFieldOffset(TestMap.class, "a");
        //System.out.println("offset1 = " + offset1);
        //final jdk.internal.misc.Unsafe unsafe1 = jdk.internal.misc.Unsafe.getUnsafe();
        //unsafe1.objectFieldOffset(TestMap.class, "a");
        // unsafe.compareAndSwapInt();
    }
}
